import {
  Body,
  Controller,
  Delete,
  Get,
  Param,
  Post,
  Query,
} from '@nestjs/common';
import { GoodService } from '../services';
import { CreateGoodDto } from '../dto/create_good.dto';
import { UpdateGoodDto } from '../dto/update_good.dto';
import { Public } from '@/modules/core/decorators/publicGuards';

import { FilterGoods } from '../dto/filter_good.dto';

@Controller('good')
export class GoodController {
  constructor(private readonly goodService: GoodService) {}
  @Get('list')
  @Public()
  async list(@Query() options: FilterGoods) {
    return await this.goodService.list(options);
  }

  @Post('create')
  async create(@Body() body: CreateGoodDto) {
    return await this.goodService.create(body);
  }

  @Delete('delete/:id')
  async delete(@Param('id') id: string) {
    return await this.goodService.delete(id);
  }

  @Get('detail/:id')
  @Public()
  async detail(@Param('id') id: string) {
    return await this.goodService.detail(id);
  }

  @Post('update/:id')
  async update(@Param('id') id: string, @Body() body: UpdateGoodDto) {
    return await this.goodService.update(id, body);
  }
}
